from enum import Enum
from typing import Callable, List, Dict

from git import Optional


class StrategyEnum(Enum):
    DD3 = ("DD3", "连续多天下跌")
    TRS = ("TRS", "Trend Reversal Strategy")

    def __init__(
        self,
        strategy_code: str,
        strategy_name: str,
    ):
        self.strategy_code = strategy_code
        self.strategy_name = strategy_name

    @staticmethod
    def get_strategy_list() -> List[Dict[str, str]]:
        """
        获取策略枚举中的所有策略信息。
        """
        return [
            {
                "strategy_code": strategy.strategy_code,
                "strategy_name": strategy.strategy_name,
            }
            for strategy in StrategyEnum
        ]

    @staticmethod
    def get_strategy_main() -> Optional["StrategyEnum"]:
        """
        根据单个策略代码获取策略枚举。
        """
        for strategy in StrategyEnum:
            if strategy.strategy_code == strategy_code:
                return strategy
        return None
